/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package migreme.parse;

import migreme.parse.ParseContent;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.Dom4JDriver;
import migreme.Item;
import migreme.exception.MigreMeException;

/**
 *
 * @author pavei
 */
public class ParseXMLMigreME implements ParseContent{

    public Item parse(String valor) throws MigreMeException{

        XStream s = new XStream(new Dom4JDriver());
        s.alias("item", Item.class);
             
        Item item = (Item) s.fromXML(valor);

       
        if (item.getError() != 0){
            throw  new MigreMeException(item.getErrormessage());
        }

        return item;

    }

    

}
